<?php


class Blackbird_Form_Users_ChangePicture extends Zend_Form
{
	function __construct($options = null)
	{
		parent::__construct($options);

		$this->setEnctype('multipart/form-data')
			->addElement('hash', 'csrf')

			->addElement('file', 'picture', array(
				'destination' => BASE_PATH . '/uploads',
				'label' => 'Fotografía:',
				'required' => true,
				'validators' => array(
					array('Extension', false, array('extension' => 'jpg,png,gif')),
					array('IsImage', false, array('image/jpeg', 'image/png', 'image/gif')),
				),
			))

			->addElement('button', 'submit', array(
				'label' => 'Cambiar imagen',
				'ignore' => true,
				'type' => 'submit',
			))

			->addElement('button', 'cancel', array(
				'label' => 'Cancelar',
				'ignore' => true,
				'type' => 'button',
				'onclick' => 'history.go(-1)',
			))
			;

		$this->csrf
			->removeDecorator('DtDdWrapper')
			->removeDecorator('Label');

		$this->submit
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'class' => 'buttons',
				'openOnly' => true,
				'tag' => 'dd',
			));

		$this->cancel
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'closeOnly' => true,
				'tag' => 'dd',
			));
	}
}

